/**
 * 扑克牌大小顺序：黑桃 > 红桃 > 梅花 > 方块
 * [0 - 51] 黑桃、红桃、梅花、方块
 * [52 - 53] 小王、大王
 */
(function () {
    window.PokerCardType = {
        unkown: -1,
        spade: 0,   // 黑桃
        heart: 1,   // 红桃
        club: 2,    // 梅花
        diamond: 3, // 方块
        joker: 4,    // 小王
        jokerKing: 5 // 大王
    };

    window.PokerCard = cc.Class({
        properties: {
            id: 0,
            value: 0,
            type: PokerCardType.unkown,
            name: ""
        },
        ctor: function () {
            var id = arguments[0] || 0;
            var typeNames = { 0: "黑桃", 1: "红桃", 2: "梅花", 3: "方块", 4: "小王", 5: "大王" };
            var valueNames = { 0: "A", 1: "2", 2: "3", 3: "4", 4: "5", 5: "6", 6: "7", 7: "8", 8: "9", 9: "10", 10: "J", 11: "Q", 12: "K" };
            this.id = id;
            if (id < 52) {
                this.type = Math.floor(id / 13);
                this.value = id % 13;
                this.name = typeNames[this.type] + valueNames[this.value];
            } else if (id < 54) {
                this.value = id - 52;
                this.type = PokerCardType.diamond + this.value;
                this.name = typeNames[this.type];
            } else {
                console.log("未知类型的ID：" + id);
            }
        }
    });
})();